/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cs575.dbentities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bms
 */
@Entity
@Table(name = "role", catalog = "tasks_management", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Role.findAll", query = "SELECT r FROM Role r"),
    @NamedQuery(name = "Role.findByRoleId", query = "SELECT r FROM Role r WHERE r.roleId = :roleId"),
    @NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.roleDescription = :RoleName")})
public class Role implements Serializable, IRole {
    @Basic(optional = false)
    @Column(name = "read_group", nullable = false)
    private boolean readGroup;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "roleId", fetch = FetchType.LAZY)
    private List<GroupInvitation> groupInvitationList;
    private static final long serialVersionUID = 1L;
    public static final int Admin = 1;
    public static final int Feeder = 2;
    public static final int Member = 3;
    
    @Id
    @Basic(optional = false)
    @Column(name = "role_id", nullable = false)
    private Integer roleId;
    @Basic(optional = false)
    @Lob
    @Column(name = "role_description", nullable = false, length = 65535)
    private String roleDescription;
    @Basic(optional = false)
    @Column(name = "invite_user", nullable = false)
    private boolean inviteUser;
    @Basic(optional = false)
    @Column(name = "remove_user", nullable = false)
    private boolean removeUser;
    @Basic(optional = false)
    @Column(name = "edit_group", nullable = false)
    private boolean editGroup;
    @Basic(optional = false)
    @Column(name = "delete_group", nullable = false)
    private boolean deleteGroup;
    @Basic(optional = false)
    @Column(name = "set_member_role", nullable = false)
    private boolean setMemberRole;
    @Basic(optional = false)
    @Column(name = "add_task_to_group", nullable = false)
    private boolean addTaskToGroup;
    @Basic(optional = false)
    @Column(name = "remove_task_from_group", nullable = false)
    private boolean removeTaskFromGroup;
    @OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
    private List<GroupMember> groupMemberList;

    public Role() {
    }

    
    public Role(Integer roleId) {
        this.roleId = roleId;
    }
    
    public Role(Integer roleId, String roleDescription){
        this.roleId = roleId;
        this.roleDescription = roleDescription;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    @Override
    public String getRoleDescription() {
        return roleDescription;
    }

    public void setRoleDescription(String roleDescription) {
        this.roleDescription = roleDescription;
    }

    @Override
    public boolean getInviteUser() {
        return inviteUser;
    }

    public void setInviteUser(boolean inviteUser) {
        this.inviteUser = inviteUser;
    }

    @Override
    public boolean getRemoveUser() {
        return removeUser;
    }

    public void setRemoveUser(boolean removeUser) {
        this.removeUser = removeUser;
    }

    @Override
    public boolean getEditGroup() {
        return editGroup;
    }

    public void setEditGroup(boolean editGroup) {
        this.editGroup = editGroup;
    }

    @Override
    public boolean getDeleteGroup() {
        return deleteGroup;
    }

    public void setDeleteGroup(boolean deleteGroup) {
        this.deleteGroup = deleteGroup;
    }

    public boolean getSetMemberRole() {
        return setMemberRole;
    }

    public void setSetMemberRole(boolean setMemberRole) {
        this.setMemberRole = setMemberRole;
    }

    @Override
    public boolean getAddTaskToGroup() {
        return addTaskToGroup;
    }

    public void setAddTaskToGroup(boolean addTaskToGroup) {
        this.addTaskToGroup = addTaskToGroup;
    }

    @Override
    public boolean getRemoveTaskFromGroup() {
        return removeTaskFromGroup;
    }

    public void setRemoveTaskFromGroup(boolean removeTaskFromGroup) {
        this.removeTaskFromGroup = removeTaskFromGroup;
    }

    @XmlTransient
    public List<GroupMember> getGroupMemberList() {
        return groupMemberList;
    }

    public void setGroupMemberList(List<GroupMember> groupMemberList) {
        this.groupMemberList = groupMemberList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roleId != null ? roleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Role)) {
            return false;
        }
        Role other = (Role) object;
        if ((this.roleId == null && other.roleId != null) || (this.roleId != null && !this.roleId.equals(other.roleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cs575.dbentities.Role[ roleId=" + roleId + " ]";
    }

    @XmlTransient
    public List<GroupInvitation> getGroupInvitationList() {
        return groupInvitationList;
    }

    public void setGroupInvitationList(List<GroupInvitation> groupInvitationList) {
        this.groupInvitationList = groupInvitationList;
    }

    public boolean getReadGroup() {
        return readGroup;
    }

    public void setReadGroup(boolean readGroup) {
        this.readGroup = readGroup;
    }
    
}
